﻿using System;

namespace VisualWip.Core
{
    public class SettingsPath : IComparable<SettingsPath>, IComparable, IEquatable<SettingsPath>
    {
        public virtual bool HasPath
        {
            get { return !string.IsNullOrWhiteSpace(Path); }
        }

        public string Path { get; set; }

        public static SettingsPath Default
        {
            get
            {
                return new SettingsPath
                           {
                               Path =
                                   System.IO.Path.Combine(
                                       Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "settings.xml")
                           };
            }
        }

        #region IComparable Members

        int IComparable.CompareTo(object obj)
        {
            return CompareTo(obj as SettingsPath);
        }

        #endregion

        #region IComparable<SettingsPath> Members

        public int CompareTo(SettingsPath other)
        {
            return StringComparer.InvariantCultureIgnoreCase.Compare(this.Path, other.Path);
        }

        #endregion

        #region IEquatable<SettingsPath> Members

        public bool Equals(SettingsPath other)
        {
            return CompareTo(other) == 0 ? true : false;
        }

        #endregion

        public override int GetHashCode()
        {
            return Path.GetHashCode();
        }

        public override bool Equals(object obj)
        {
            return Equals(obj as SettingsPath);
        }
    }
}